package jgame;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;

public class GuiManager {
	GameManager gameManager;
	LogField logField = new LogField();
	JScrollPane logScrollPane;
	JList unitList;
	public DrawPanel drawPanel;
	
	static GuiManager instance;
	
	public static GuiManager getInstance()
	{
		instance = instance == null ? new GuiManager() : instance;
		return instance;
	}
	
	public GuiManager() {
		
		JFrame frm = new JFrame();
		frm.setSize(840, 480);
		frm.setVisible(true);
		frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frm.setBackground(new Color(100, 100, 100));
		
		
		
		
		Container pane = frm.getContentPane();
		
		
		this.logField.setSize(300, 480);
		
		this.unitList = new JList();
		this.unitList.setSize(200, 480);
		
		logScrollPane = new JScrollPane(logField);
		
		logScrollPane.setVerticalScrollBarPolicy(
		                JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		logScrollPane.setPreferredSize(new Dimension(300, 480));
		logScrollPane.setMinimumSize(new Dimension(100, 100));
		logScrollPane.setVisible(true);

		drawPanel = new DrawPanel();
		drawPanel.setSize(300, 300);
		drawPanel.setVisible(true);
		
		pane.add(logScrollPane, BorderLayout.WEST);
		pane.add(drawPanel, BorderLayout.CENTER);
	}
	
	public LogField getLogField()
	{
		return this.logField;
	}
	
	public void setGameManager(GameManager gameManager) {
		this.gameManager = gameManager;
		this.drawPanel.setGameManager(gameManager);
	}
}
